import { http } from "@/utils/http";
import { baseUrlApi, filerEmptyVal } from "../utils";

/** 获取基础档案-供应商管理列表 */
export const getSupplierPage = (params?: object) => {
  return http.request<any>("get", baseUrlApi("/supplier/page"), {
    params: filerEmptyVal(params)
  });
};

/** 获取基础档案-供应商管理列表 */
export const getSupplierSimplePage = (params?: object) => {
  return http.request<any>("get", baseUrlApi("/supplier/simple/page"), {
    params: filerEmptyVal(params)
  });
};

/** 基础档案-供应商管理列表-新增供应商 */
export const supplierAdd = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/supplier/add"), { data });
};

/** 基础档案-供应商管理列表-编辑供应商 */
export const supplierUpdate = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/supplier/update"), { data });
};

/** 基础档案-供应商管理列表-删除供应商 */
export const supplierDelete = (id?: object) => {
  return http.request<any>("post", baseUrlApi(`/supplier/delete?id=${id}`));
};

/** 获取基础档案-供应商管理列表详情 */
export const getSupplierDetail = (params?: object) => {
  return http.request<any>("get", baseUrlApi("/supplier/detail"), { params });
};

/** 基础档案-供应商管理列表-状态启用禁用 */
export const supplierChangeStatus = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/supplier/change/status"), {
    data
  });
};

/** 导入供应商列表 */
export const importSupplier = (data?: any) => {
  return http.request<any>(
    "post",
    `/erpPlatApi/supplier/import/supplier`,
    {
      data,
      params: {
        isShowErrTips: false
      }
    },
    {
      headers: {
        "Content-Type": "multipart/form-data"
      }
    }
  );
};

/** 导出供应商列表 */
export const exportSupplier = (params?: any) => {
  return http.request<any>(
    "get",
    `/erpPlatApi/supplier/export/supplier`,
    { params: filerEmptyVal(params) },
    { responseType: "blob" }
  );
};
